<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>广场</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/style.css" />
    <link rel="stylesheet" href="../lib/mui-master/dist/css/mui.min.css">
    <link rel="stylesheet" href="../css/aui.css">
    <link rel="stylesheet" href="../icon/iconfont.css">
    <link rel="stylesheet" type="text/css" href="../css/frame2.css" />

</head>
  <style>
  .news{
    position: fixed;
    bottom: 0rem;
    line-height: 1.6rem;
    display: none;
  }
  .news input{
    display: inline-block;
    height: 1.6rem;
    background-color: rgb(242, 246, 247);
    width: 12rem;
    vertical-align: top;
    padding-left: 0.5rem;
    border: none;
    border-radius: 0;
    margin-right: 0.2rem
  }
  .news button{
    display: inline-block;
    width: 4.5rem;
    height: 1.6rem;
    border-radius: 0;
    background-color: rgb(197, 22, 26);
    color: #fff;
    vertical-align: top;
    border: none;
  }
  .zan_icon{
    color:rgb(96, 96, 96)
  }
  .zan_icon.active {
      color: rgb(201, 22, 26);
  }

  </style>
<body style="position:relative">
    <div class="empty" style="overflow:hidden">
        <!-- 轮播图 -->
        <div id="slider" class="mui-slider" style="position: fixed;">
            <div class="mui-slider-group mui-slider-loop" id="mui_banner" style="height:8rem;">

            </div>
            <div class="mui-slider-indicator">

            </div>
        </div>


        <div class="content" id="content" style="padding-top:8.8rem">

        </div>
        <!-- 编辑 -->
        <div class="compile" onclick="btn_compile()">
            <span class="iconfont icon-xiangji1" style="font-size: 1.1rem;"></span>
        </div>
        <div id="down" style="height:1rem;text-align:center;display:none;font-size:0.7rem;color:#ccc">
          ---人家也是有底线的!---
        </div>
    </div>
    <script type="text/javascript" src='../script/jquery-3.3.1.js'></script>
    <script type="text/javascript" src='../script/api.js'></script>
    <script type="text/javascript" src="../lib/artTemplate/template.js"></script>
    <script type="text/javascript" src='../script/dns.js'></script>
    <script type="text/javascript" src='../lib/mui-master/dist/js/mui.min.js'></script>
    <script type="text/javascript" src='../script/aui-toast.js'></script>

    <script type="text/html" id="contentList">
    {{each items as value index}}
    <div class="content_header" style="border-bottom:1px solid #EEE;margin:0 0 .5rem 0;">
        <div class="head_photo">
            <img src="{{value.user.avatar.filepath}}" alt="">
        </div>
        <div class="head_right">
            <h4 class="screen_name">{{value.user.nickname}}</h4>
            <p class="say">{{value.content}}</p>
            <!-- 图片 -->
            <div class="photo">
                <div class="aui-row aui-row-padded photoList">
                    {{each value.img as val ind}}
                      <div class="aui-col-xs-4" imgattr="{{val.filepath}}" style="overflow:hidden;text-align:center;height:4.7rem" onclick="bigPhoto(this)">
                          <img class="imgList" style="width:100%;height:100%;background-image:url('{{val.filepath}}?imageslim');background-size:cover"/>
                      </div>
                    {{/each}}
                </div>
            </div>
            <!-- 点赞，评论 -->
            <div class="footer">
                <span class="read" style="font-weight: 400;">{{value.create_time}}</span>
                <div class="footer_right" activeId="{{value.id}}">
                    <span class="iconfont icon-pinglunzhuanhuan btn_comment" style="color:rgb(96, 96, 96)" onclick="comment(this)"></span><span class="comment" style="color:rgb(96, 96, 96)">{{value.comment_num}}</span>
                    {{if value.tid.is_awesome=="yes"}}
                    <span class="zan" style="margin-left:12px" onclick="getdianzan(this)"><span class="iconfont icon-dianzan zan_icon active">&nbsp;</span><span class="like" style="color:rgb(96, 96, 96)">{{value.awesome_num}}</span></span>
                    {{/if}}
                    {{if value.tid.is_awesome=="no"}}
                    <span class="zan" style="margin-left:12px" onclick="getdianzan(this)"><span class="iconfont icon-dianzan zan_icon">&nbsp;</span><span class="like" style="color:rgb(96, 96, 96)">{{value.awesome_num}}</span></span>
                    {{/if}}
                </div>
            </div>

          <div class="footer_comment"   {{if value.comment_num == 0 && value.awesome_num == 0}} style="display:none;"{{/if}}>
              <div class="comment_one" style="min-height:1rem">
                  <span class="iconfont icon-dianzan icon{{value.id}}" style="margin-right:8px"></span>
                    <!-- {{each value.like_list as val ind}}
                      <span style="color: rgb(61, 106, 157);">{{val.user.nickname}}、</span>
                    {{/each}} -->
                    {{if value.like_list.length<=2}}
                      {{each value.like_list as val ind}}
                        <span style="color: rgb(61, 106, 157);">{{val.user.nickname}}、</span>
                      {{/each}}
                    {{/if}}
                    {{if value.like_list.length>2}}
                      <span style="color: rgb(61, 106, 157);">{{value.like_list[0].user.nickname}}、</span>
                      <span style="color: rgb(61, 106, 157);">{{value.like_list[1].user.nickname}}</span>等<i style="font-style:normal">{{value.awesome_num}}</i>人觉得很赞！
                    {{/if}}
              </div>
              <div>
                  <div class="commentList{{value.id}} updown commentList" style="margin-top:0.2rem">
                    {{each value.comment_list as val ind}}
                      <p>
                          <span style="color: rgb(29, 29, 29);font-weight: 300;"><span class="nickname_comment">{{val.user.nickname}}：</span>{{#val.content}}</span>
                      </p>
                    {{/each}}
                  </div>
                  <div style="height:0.9rem;text-align:center"><span class="iconfont icon-xiangshangjiantouarrowup1 down" style="font-size:0.8rem;color:#ccc" onclick="moreComment(this)"></span></div>
              </div>
          </div>

        </div>
    </div>
    {{/each}}
    </script>
    <script>
        apiready = function() {
          bannnerList();
          getcontentList(1);
          refreshList();
        }
        var toast = new auiToast({
            })
        // 编辑
        function btn_compile() {
          // 获取此时的毫秒数
          var newTime = new Date();
          var getnewTime = newTime.getTime();
          // 获取登陆时的毫秒数
          var getloginTime = localStorage.getItem("getloginTime");
          var Time = getnewTime-getloginTime;
          var token = localStorage.getItem("token");
          var cacheTime = localStorage.getItem("cacheTime");
          if(Time>cacheTime||!token){
            api.confirm({
                title: "当前游客状态",
                msg: "需要前往登录页面,是否继续?",
                buttons: ["是", "否"]
            }, function(ret, err) {
              if(ret.buttonIndex == 1){
                toast.loading({
                        title:"跳转中",
                        duration:2000
                    },function(ret){
                        setTimeout(function(){
                            toast.hide();
                        }, 3000)
                    });
                setTimeout(function () {
                  api.openWin({
                      name: 'login',
                      url: './system/login.html',
                      allowEdit: true,
                      pageParam: {}, //页面代参数
                      rect: {
                          x: 0,
                          y: 0,
                          w: api.winWidth,
                          h: api.winHeight
                      }
                  });
                },1000)
              }
            });
            return false;
          }
            api.openWin({
                name: 'compile',
                url: './frame2/compile.html',
                allowEdit:true,
                rect: {
                    x: 0,
                    y: 0,
                    w: api.winWidth,
                    h: api.winHeight
                }
            });
        }

        // 轮播图
        function bannnerList() {
          $.ajax({
            type:"get",
            data:{
              type_id:2
            },
            url:dns+"banner/read",
            success:function(res){
              // console.log(JSON.stringify(res));
              $(".mui-slider-group").empty();
              $(".mui-slider-indicator").empty();
              var length = res.data.length;
              if(length==1){
                $(".mui-slider-group").append('<div class="mui-slider-item" activeId="'+res.data[0].href_url+'"><img class="lunbo-img" src="' + res.data[0].img_id.url + '" /></div>')
              }else{
                $('.mui-slider-group').append('<div class="mui-slider-item mui-slider-item-duplicate" activeId="'+res.data[length-1].href_url+'"><img class="lunbo-img" src="' + res.data[length-1].img_id.url + '" /></div>');
                $('.mui-slider-indicator').append('<div class="mui-indicator mui-active"></div>');
                for(var i = 0; i < length; i++) {
                    $('.mui-slider-group').append('<div class="mui-slider-item" activeId="'+res.data[i].href_url+'"><img class="lunbo-img" src="' + res.data[i].img_id.url + '" /></div>');
                }
                $('.mui-slider-group').append('<div class="mui-slider-item mui-slider-item-duplicate" activeId="'+res.data[0].href_url+'"><img class="lunbo-img" src="' + res.data[0].img_id.url + '" /></div>');
                for(var i = 0; i < length - 1; i++) {
                    $('.mui-slider-indicator').append('<div class="mui-indicator"></div>');
                }
              };
              var gallery = mui('.mui-slider');
                  gallery.slider({
                    interval: 5000 //自动轮播周期，若为0则不自动播放，默认为0；
              });
              // 点击图片跳转对应详情
              $(".mui-slider-item").each(function () {
                $(this).click(function () {
                  var activeId = $(this).attr("activeId");//自定义属性的值
                  var index = activeId.indexOf("=");//索引
                  var type = activeId.substr(0,index);//类型
                  var id = activeId.substr(index+1);//id
                  if(type=="news"){
                    localStorage.setItem("articleID",id)
                    api.openWin({
                        name: 'article',
                        url: './frame0/article.html',
                        allowEdit:true,
                        pageParam: {}, //页面代参数
                        rect: {
                            x: 0,
                            y: 0,
                            w: api.winWidth,
                            h: api.winHeight
                        }
                    });
                  };
                  if(type=="booking"){
                    localStorage.setItem("articleID",id)
                    api.openWin({
                        name: 'frame1-details',
                        url: './frame1/frame1_details.html',
                        allowEdit:true,
                        pageParam: {}, //页面代参数
                        rect: {
                            x: 0,
                            y: 0,
                            w: api.winWidth,
                            h: api.winHeight
                        }
                    });
                  };

                })
              })
            }
          })
        }
        // 列表数据渲染
        function getcontentList(page) {
          var token = localStorage.getItem("token")
          $.ajax({
            type:"post",
            beforeSend:function (request) {
              request.setRequestHeader("token",token)
            },
            data:{
              page:page,
              limit:20
            },
            url:dns+"square/read",
            success:function(res){
              for(var i = 0;i<res.data.length;i++){
                for(j = 0; j<res.data[i].comment_list.length;j++){
                  var msg = res.data[i].comment_list[j].content;
                  res.data[i].comment_list[j].content = transEmo(msg)
                }
              }
              var html = template("contentList", {"items": res.data});
              document.getElementById("content").innerHTML = html;
              api.addEventListener({
                  name: "compile_reload"
              }, function(ret, err) {
                  $.ajax({
                    type:"post",
                    beforeSend:function (request) {
                      request.setRequestHeader("token",token)
                    },
                    data:{
                      page:1,
                      limit:1
                    },
                    url:dns+"square/read",
                    success:function(res){
                      var html = template("contentList", {"items": res.data});
                      $("#content").prepend(html)
                    }
                  })
              })
              // 监听页面到达最底部时上拉加载
              var page = 1;
              api.addEventListener({
                  name:'scrolltobottom',
                  extra:{
                      threshold:0            //设置距离底部多少距离时触发，默认值为0，数字类型
                  }
              }, function(ret, err){
                  page++;
                  var token = localStorage.getItem("token");
                  $.ajax({
                    type:"post",
                    beforeSend:function (request) {
                      request.setRequestHeader("token",token)
                    },
                    data:{
                      page:page,
                      limit:20
                    },
                    url:dns+"square/read",
                    success:function(res){
                      // console.log(JSON.stringify(res));
                      if(res.count==0){
                        $("#down").css("display","block");
                        return false;
                      }
                      for(var i = 0;i<res.data.length;i++){
                        for(j = 0; j<res.data[i].comment_list.length;j++){
                          var msg = res.data[i].comment_list[j].content;
                          res.data[i].comment_list[j].content = transEmo(msg)
                        }
                      }
                      var html = template("contentList", {"items": res.data});
                      $("#content").append(html);
                    }
                  })
              });
            },
            error:function(err){
              console.log(JSON.parse(err.responseText).msg);
            }
          })
        }
        // 点赞，取消点赞
        function getdianzan(e) {
          // 获取此时的毫秒数
          var newTime = new Date();
          var getnewTime = newTime.getTime();
          // 获取登陆时的毫秒数
          var getloginTime = localStorage.getItem("getloginTime");
          var Time = getnewTime-getloginTime;
          var token = localStorage.getItem("token");
          var cacheTime = localStorage.getItem("cacheTime");
          if(Time>cacheTime||!token){
            api.confirm({
                title: "当前游客状态",
                msg: "需要前往登录页面,是否继续?",
                buttons: ["是", "否"]
            }, function(ret, err) {
              if(ret.buttonIndex == 1){
                toast.loading({
                        title:"跳转中",
                        duration:2000
                    },function(ret){
                        setTimeout(function(){
                            toast.hide();
                        }, 3000)
                    });
                setTimeout(function () {
                  api.openWin({
                      name: 'login',
                      url: './system/login.html',
                      allowEdit: true,
                      pageParam: {}, //页面代参数
                      rect: {
                          x: 0,
                          y: 0,
                          w: api.winWidth,
                          h: api.winHeight
                      }
                  });
                },1000)
              }
            });
            return false;
          }
            var articleID = $(e).parent().attr("activeID");
            var val = $(e).find(".like").text();
            $.ajax({
                type: "post",
                data: {
                    type: 3,
                    article: articleID
                },
                beforeSend: function(request) {
                    request.setRequestHeader("token", token);
                },
                url: dns + "like/okorno",
                success: function(res){
                  if(res.msg=="成功点赞"){
                    $(e).find(".zan_icon").addClass("active");
                    val++;
                    $(e).parents(".footer").siblings(".footer_comment").find("i").html(val)
                    $(e).find(".like").text(val);
                    var nickName = res.data.nickname;
                    var strVar="";
                    strVar += "<span style=\"color: rgb(61, 106, 157);\">"+nickName+"、</span>";
                    $(".icon"+articleID).after(strVar);
                    //点赞之后监听是否显示评论窗口
                    var plnum = $(e).parents('.footer_right').find('.comment').html();
                    if(val ==0 && plnum ==0 ){
                      $(e).parents('.footer').siblings('.footer_comment').hide();
                    }else{
                        $(e).parents('.footer').siblings('.footer_comment').show();
                    }
                    toast.custom({
                      title:"成功点赞!",
                      html:'<i class="aui-iconfont aui-icon-laud"></i>',
                      duration:1500
                    });
                  };
                  if(res.msg=="取消点赞"){
                    $(e).find(".zan_icon").removeClass("active");
                    val--;
                    $(e).parents(".footer").siblings(".footer_comment").find("i").html(val)
                    $(e).find(".like").text(val);
                    $(".icon"+articleID).next().remove();
                    //点赞之后监听是否显示评论窗口
                    var plnum = $(e).parents('.footer_right').find('.comment').html();
                    if(val ==0 && plnum ==0 ){
                      $(e).parents('.footer').siblings('.footer_comment').hide();
                    }else{
                        $(e).parents('.footer').siblings('.footer_comment').show();
                    }
                  }
                }
            });
        }

        //该方法用来下拉刷新
        function refreshList() {
            // api.setRefreshHeaderInfo({
            //     visible: true, //是否可见，若设置为false，下拉区域不能隐藏且刷新界面为黑色，什么内容也看不到。
            //     bgColor: '#ccc', //背景色
            //     textColor: '#fff', //文本颜色
            //     textDown: '下拉刷新...', //下拉文字描述，默认值：下拉可以刷新
            //     textUp: '松开刷新...', //松开时文字描述，默认值：松开可以刷新
            //     textLoading: '加载中..', //加载状态文字描述
            //     //textTime:'',，//更新时间文字描述,默认格式为：最后更新+日期时间
            //     showTime: true //是否需显示更新时间
            // }, function(ret, err) {
            //     //alert("下拉刷新成功");
            //     api.refreshHeaderLoadDone(); //恢复默认状态
            //
            //     //重新加载当前页面
            //     window.location.reload();
            // });
            api.setCustomRefreshHeaderInfo({
                  bgColor: '#eee',
                  images: [
                    'widget://image/xiaolong/1.png',
                    'widget://image/xiaolong/2.png',
                    'widget://image/xiaolong/3.png',
                    'widget://image/xiaolong/4.png',
                    'widget://image/xiaolong/5.png',
                  ],
                  tips: {
                    pull: '下拉刷新' + '\n',
                    threshold: '松开立即刷新' + '\n',
                    load: '正在刷新' + '\n'
                  }
                  }, function() {
                    setTimeout(function(){
                       api.refreshHeaderLoadDone();
                        window.location.reload();
                }, 1000);
            });
        }
        // 开启评论模块
        function comment(e) {
          // 获取此时的毫秒数
          var newTime = new Date();
          var getnewTime = newTime.getTime();
          // 获取登陆时的毫秒数
          var getloginTime = localStorage.getItem("getloginTime");
          var Time = getnewTime-getloginTime;
          var token = localStorage.getItem("token");
          var cacheTime = localStorage.getItem("cacheTime");
          if(Time>cacheTime||!token){
            api.confirm({
                title: "当前游客状态",
                msg: "需要前往登录页面,是否继续?",
                buttons: ["是", "否"]
            }, function(ret, err) {
              if(ret.buttonIndex == 1){
                toast.loading({
                        title:"跳转中",
                        duration:2000
                    },function(ret){
                        setTimeout(function(){
                            toast.hide();
                        }, 3000)
                    });
                setTimeout(function () {
                  api.openWin({
                      name: 'login',
                      url: './system/login.html',
                      allowEdit: true,
                      pageParam: {}, //页面代参数
                      rect: {
                          x: 0,
                          y: 0,
                          w: api.winWidth,
                          h: api.winHeight
                      }
                  });
                },1000)
              }
            });
            return false;
          }
          var UIChatBox = api.require('UIChatBox');
          UIChatBox.open({
            placeholder: '说出你的想法~',
            maxRows: 4,
            emotionPath: 'widget://widget/image/emotion',
            texts: {
                sendBtn: {
                    title: 'send'
                }
            },
            styles: {
                inputBar: {
                    borderColor: '#d9d9d9',
                    bgColor: '#f2f2f2'
                },
                inputBox: {
                    borderColor: '#B3B3B3',
                    bgColor: '#FFFFFF'
                },
                emotionBtn: {     //笑脸
                    normalImg: '../widget/image/face1.png'
                },
                keyboardBtn: {     //键盘
                    normalImg: '../widget/image/key1.png'
                },
                indicator: {
                    target: 'emotionPanel',
                    color: '#c4c4c4',
                    activeColor: '#9e9e9e'
                },
                sendBtn: {
                    titleColor: '#fff',
                    bg: 'rgb(99, 149, 236)',
                    activeBg: 'rgb(99, 149, 236)',
                    titleSize: 14
                }
              },
              isClose:true
          },function(ret, err){
            if(ret){
              var msg = JSON.stringify(ret.msg);
              var msg = msg.substr(1,msg.length-2);
              var msg = msg.trim();
              var activeId = $(e).parent().attr("activeId");
              var token = localStorage.getItem("token");
              if(msg==''){
                toast.fail({
                    title:"请输入您想评论的内容!",
                    duration:2000
                });
                return false;
              };
              // 发表评论
              $.ajax({
                type:"post",
                data:{
                  token:token,
                  content:msg,
                  type:3,
                  article:activeId
                },
                beforeSend: function(request) {
                    request.setRequestHeader("token", token);
                },
                url:dns+"comment/create",
                success:function(res){
                  var nickname = res.data.user.nickname;
                  var content = transEmo(res.data.content.content);
                  setTimeout(function () {
                    toast.success({
                      title:"评论成功!",
                      duration:2000
                    });
                  },500)
                  //动态添加评论
                  var strVar="";
                  strVar += "<p>";
                  strVar += "                            <span style=\"color: rgb(29, 29, 29);font-weight: 300;\"><span class=\"nickname_comment\">"+nickname+"：</span>"+content+"</span>";
                  strVar += "                        <\/p>";
                  $(".commentList"+activeId).append(strVar);
                  // 评论之后监听是否显示评论窗口
                  var dznum = $(e).parent('.footer_right').find('.zan').find('.like').html();
                  var currentVal = parseInt($(e).siblings('.comment').html());
                  currentVal += 1;
                  $(e).siblings('.comment').html(currentVal);
                  if(dznum == 0 && currentVal == 0){
                    $(e).parents('.footer').siblings('.footer_comment').hide();
                  }else{
                    $(e).parents('.footer').siblings('.footer_comment').show();
                  }
                  // 关闭聊天框
                  var UIChatBox = api.require('UIChatBox');
                  UIChatBox.close();
                },
                error:function(err){
                  alert(JSON.stringify(err));
                }
              })
            }else{
              alert(JSON.stringify(err))
            }
          });
          // 弹出键盘
          UIChatBox.popupKeyboard();
        };
        //表情配置信息
        var emoData = [
            {"name": "Expression_1","text": "[微笑]"},
            {"name": "Expression_2","text": "[撇嘴]"},
            {"name": "Expression_3","text": "[色]"},
            {"name": "Expression_4","text": "[发呆]"},
            {"name": "Expression_5","text": "[得意]"},
            {"name": "Expression_6","text": "[流泪]"},
            {"name": "Expression_7","text": "[害羞]"},
            {"name": "Expression_8","text": "[闭嘴]"},
            {"name": "Expression_9","text": "[睡]"},
            {"name": "Expression_10","text": "[大哭]"},
            {"name": "Expression_11","text": "[尴尬]"},
            {"name": "Expression_12","text": "[发怒]"},
            {"name": "Expression_13","text": "[调皮]"},
            {"name": "Expression_14","text": "[呲牙]"},
            {"name": "Expression_15","text": "[惊讶]"},
            {"name": "Expression_16","text": "[难过]"},
            {"name": "Expression_17","text": "[酷]"},
            {"name": "Expression_18","text": "[冷汗]"},
            {"name": "Expression_19","text": "[抓狂]"},
            {"name": "Expression_20","text": "[吐]"},
            {"name": "Expression_21","text": "[偷笑]"},
            {"name": "Expression_22","text": "[愉快]"},
            {"name": "Expression_23","text": "[白眼]"},
            {"name": "Expression_24","text": "[傲慢]"},
            {"name": "Expression_25","text": "[饥饿]"},
            {"name": "Expression_26","text": "[困]"},
            {"name": "Expression_27","text": "[恐惧]"},
            {"name": "Expression_28","text": "[流汗]"},
            {"name": "Expression_29","text": "[憨笑]"},
            {"name": "Expression_30","text": "[悠闲]"},
            {"name": "Expression_31","text": "[奋斗]"},
            {"name": "Expression_32","text": "[咒骂]"},
            {"name": "Expression_33","text": "[疑问]"},
            {"name": "Expression_34","text": "[嘘]"},
            {"name": "Expression_35","text": "[晕]"},
            {"name": "Expression_36","text": "[疯了]"},
            {"name": "Expression_37","text": "[衰]"},
            {"name": "Expression_38","text": "[骷髅]"},
            {"name": "Expression_39","text": "[敲打]"},
            {"name": "Expression_40","text": "[再见]"},
            {"name": "Expression_41","text": "[擦汗]"},
            {"name": "Expression_42","text": "[抠鼻]"},
            {"name": "Expression_43","text": "[鼓掌]"},
            {"name": "Expression_44","text": "[糗大了]"},
            {"name": "Expression_45","text": "[坏笑]"},
            {"name": "Expression_46","text": "[左哼哼]"},
            {"name": "Expression_47","text": "[右哼哼]"},
            {"name": "Expression_48","text": "[哈欠]"},
            {"name": "Expression_49","text": "[鄙视]"},
            {"name": "Expression_50","text": "[委屈]"},
            {"name": "Expression_51","text": "[快哭了]"},
            {"name": "Expression_52","text": "[阴险]"},
            {"name": "Expression_53","text": "[亲亲]"},
            {"name": "Expression_54","text": "[吓]"},
            {"name": "Expression_55","text": "[可怜]"},
            {"name": "Expression_56","text": "[菜刀]"},
            {"name": "Expression_57","text": "[西瓜]"},
            {"name": "Expression_58","text": "[啤酒]"},
            {"name": "Expression_59","text": "[篮球]"},
            {"name": "Expression_60","text": "[乒乓]"},
            {"name": "Expression_61","text": "[咖啡]"},
            {"name": "Expression_62","text": "[饭]"},
            {"name": "Expression_63","text": "[猪头]"},
            {"name": "Expression_64","text": "[玫瑰]"},
            {"name": "Expression_65","text": "[凋谢]"},
            {"name": "Expression_66","text": "[嘴唇]"},
            {"name": "Expression_67","text": "[爱心]"},
            {"name": "Expression_68","text": "[心碎]"},
            {"name": "Expression_69","text": "[蛋糕]"},
            {"name": "Expression_70","text": "[闪电]"},
            {"name": "Expression_71","text": "[炸弹]"},
            {"name": "Expression_72","text": "[刀]"},
            {"name": "Expression_73","text": "[足球]"},
            {"name": "Expression_74","text": "[瓢虫]"},
            {"name": "Expression_75","text": "[便便]"},
            {"name": "Expression_76","text": "[月亮]"},
            {"name": "Expression_77","text": "[太阳]"},
            {"name": "Expression_78","text": "[礼物]"},
            {"name": "Expression_79","text": "[拥抱]"},
            {"name": "Expression_80","text": "[强]"},
            {"name": "Expression_81","text": "[弱]"},
            {"name": "Expression_82","text": "[握手]"},
            {"name": "Expression_83","text": "[胜利]"},
            {"name": "Expression_84","text": "[抱拳]"},
            {"name": "Expression_85","text": "[勾引]"},
            {"name": "Expression_86","text": "[拳头]"},
            {"name": "Expression_87","text": "[差劲]"},
            {"name": "Expression_88","text": "[爱你]"},
            {"name": "Expression_89","text": "[NO]"},
            {"name": "Expression_90","text": "[OK]"},
            {"name": "Expression_91","text": "[爱情]"},
            {"name": "Expression_92","text": "[飞吻]"},
            {"name": "Expression_93","text": "[跳跳]"},
            {"name": "Expression_94","text": "[发抖]"},
            {"name": "Expression_95","text": "[怄火]"},
            {"name": "Expression_96","text": "[转圈]"},
            {"name": "Expression_97","text": "[磕头]"},
            {"name": "Expression_98","text": "[回头]"},
            {"name": "Expression_99","text": "[跳绳]"},
            {"name": "Expression_100","text": "[投降]"},
            {"name": "Expression_101","text": "[激动]"},
            {"name": "Expression_102","text": "[街舞]"},
            {"name": "Expression_103","text": "[献吻]"},
            {"name": "Expression_104","text": "[左太极]"},
            {"name": "Expression_105","text": "[右太极]"}
        ];
        //文字表情转换
        function transEmo(emoMsg){
            var emoPath, transMsg;
                var reg = /\[(.*?)\]/gm;
                transMsg = emoMsg.replace(reg, function(match) {
                        for (var i = 0, len = emoData.length; i < len; i++) {
                                if (emoData[i].text === match) {
                                        emoPath = '../widget/image/emotion/' + emoData[i].name + '.png';
                                        return '<img width="18" height="18" style="vertical-align:text-bottom" src="' + emoPath + '" />'
                                }
                        }
                        return match;
                });
                return transMsg;
        }
        // 更多评论按钮
        function moreComment(e) {
            var boolean = $(e).parent().prev().hasClass("updown");
            if(boolean){
              $(e).parent().prev().removeClass("updown");
              $(e).removeClass("icon-xiangshangjiantouarrowup1")
              $(e).addClass("icon-xiangshangjiantouarrowup")
            }else{
              $(e).parent().prev().addClass("updown");
              $(e).removeClass("icon-xiangshangjiantouarrowup")
              $(e).addClass("icon-xiangshangjiantouarrowup1")
            }
        }
        // 放大图片
        function bigPhoto(e) {
              var ind = $(e).index();
              var imgList = [];
              $(e).parent().find(".aui-col-xs-4").each(function () {
                imgList.push($(this).attr("imgattr"));
              })
              var photoBrowser = api.require('photoBrowser');
              photoBrowser.open({
                  images: imgList,
                  placeholderImg: 'widget://res/img/apicloud.png',
                  bgColor: '#000',
                  activeIndex:ind

              }, function(ret, err) {
                  // console.log(JSON.stringify(ret));
                  if (ret.eventType == 'click') {
                      photoBrowser.close()
                  }
                  if (ret.eventType == 'longPress') {
                    var a = Math.floor(Math.random()*1000);//随机数解决安卓图片保存仅一张问题
                    var retIndex = ret.index;
                    api.confirm({
                        title: "温馨提示",
                        msg: "是否保存图片?",
                        buttons: ["是", "否"]
                    }, function(ret, err) {
                        if (ret.buttonIndex == 1) { //确认退出
                          api.download({
                              url: imgList[retIndex],
                              savePath: 'fs://'+a+'.jpg',
                              report: true,
                              cache: false
                          }, function(ret, err) {
                              if (ret.state == 1) {
                                  //下载成功
                                  // console.log("下载成功");
                                  // 保存图片
                                  api.saveMediaToAlbum({
                                    path :ret.savePath
                                  }, function(ret, err) {
                                      if (ret.status==true) {
                                        alert("保存成功!")
                                      } else {
                                      }
                                  });
                              } else {

                              }
                          });
                        } else {
                            return;
                        }
                    });
                  }
                   else {
                      // alert(JSON.stringify(err));
                  }
              });

        }
    </script>
</body>
</html>
